package com.augmentum.springcloudorderservice.service;

import com.augmentum.springcloudorderservice.domain.orderitem.OrderItem;
import com.augmentum.springcloudorderservice.domain.orderitem.OrderItemRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;

@Service
public class OrderItemService {
    @Resource
    private OrderItemRepository orderItemRepository;

    public OrderItem create(OrderItem orderItem) {
        return orderItemRepository.save(orderItem);
    }

    @Transactional
    public List<OrderItem> create(List<OrderItem> orderItems) {
        return orderItemRepository.saveAll(orderItems);
    }
}
